<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui"
	xmlns:ui="http://java.sun.com/jsf/facelets">

<h:head>
	<link type="text/css" rel="stylesheet"
		href="#{request.contextPath}/CSS/style.css" />
	<title>Località</title>
</h:head>
<h:body>
	<div id="header">
		<ui:include src="/snippets/header.xhtml"></ui:include>
	</div>
	<ui:include src="menù.xhtml">
		<ui:param name="tabSelected" value="1" />
	</ui:include>
	<table id="content" align="center">
		<tr>
			<td id="messageCol" align="center" colspan="2"><p:messages
					id="messages" showDetail="true" autoUpdate="false" closable="true"
					for="regSubmit" /></td>
		</tr>
		<tr>
			<td id="listCol" valign="top"><h:form id="listForm">
					<p:contextMenu for="listLocalità">
						<p:menuitem value="Elimina" update="listLocalità, :messages"
							icon="ui-icon-close"
							actionListener="#{prodottiBean.cancellaLocalità}" />
					</p:contextMenu>

					<p:dataTable id="listLocalità" var="loc"
						value="#{prodottiBean.listaLocalità()}" rowKey="#{loc.id}"
						selection="#{prodottiBean.località}" selectionMode="single"
						emptyMessage="Nessuna località inserita" paginator="true"
						rows="10" rowsPerPageTemplate="5,10,15"
						filteredValue="#{prodottiBean.filteredLocalità}">
						<f:facet name="header">Lista Località</f:facet>
						<p:column headerText="Id" filterBy="id" filterMatchMode="contains">
							<h:outputText value="#{loc.id}" />
						</p:column>
						<p:column headerText="Nome completo" filterBy="nome"
							filterMatchMode="contains">
							<h:outputText value="#{loc.nome}" />
						</p:column>
						<f:facet name="footer">
							<h:outputText
								value="in totale: #{prodottiBean.numLocalità} località" />
						</f:facet>
					</p:dataTable>
				</h:form></td>
			<td id="regCol" valign="top"><h:form id="regForm">
					<p:panel header="Modulo di Creazione">
						<h:panelGrid columns="3" id="regGrid">
							<h:outputLabel for="id">Id:</h:outputLabel>
							<p:inputText id="id" value="#{prodottiBean.località.id}" />
							<p:message id="msgId" for="id" />

							<h:outputLabel for="nome">Nome:</h:outputLabel>
							<p:inputText id="nome" value="#{prodottiBean.località.nome}" />
							<p:message id="msgNome" for="nome" />
						</h:panelGrid>
						<br />
						<p:commandButton id="regSubmit" value="Crea"
							update="regGrid, :listForm:listLocalità, :messages"
							actionListener="#{prodottiBean.creaLocalità}"
							icon="ui-icon-carat-1-e" iconPos="right" />
					</p:panel>
				</h:form></td>
		</tr>
	</table>
</h:body>
</html>
